package com.example.pmqt.common;

import cn.hutool.core.util.PageUtil;
import lombok.Data;


@Data
public class PageResult {

    private Integer current_page;
    private Integer page_size;
    private Integer total;
    private Integer totalpage;
    private Object data;

    private int[] displaycount;

    public PageResult() {
    }



    public static PageResult buildPage(Integer current_page, Integer page_size, Integer total,Integer displaycount, Object data) {
        PageResult result = new PageResult();
        result.current_page = current_page;
        result.page_size = page_size;
        result.total = total;
        if (total % page_size != 0) {
            result.totalpage = total / page_size+1;
        }else {
            result.totalpage = total / page_size;
        }
        result.displaycount = PageUtil.rainbow(current_page, result.totalpage, displaycount);
        result.data = data;
        return result;
    }
}
